const { defineConfig } = require('@vue/cli-service')
const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}

module.exports = defineConfig({
  transpileDependencies: true,
  chainWebpack: config => {
    config.plugin('define').tap(definitions => {
      Object.assign(definitions[0], {
        __VUE_OPTIONS_API__: "true",
        __VUE_PROD_DEVTOOLS__: "false",
        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false"
      })
      return definitions
    })
    config.resolve.alias
      .set('@', resolve('src')) // 配置src目录别名
      .set('style', resolve('src/style')) // 配置src/style目录别名
      .set('assets', resolve('src/assets')) // 配置src/assets目录别名
      .set('components', resolve('src/components')) // 配置src/components目录别名
  },
  devServer: {
    proxy: {
      user: {
        target: 'http://127.0.0.1:6300/',
        changeOrigin: true,
        pathRewrite: {
          '^user/': 'user/'
        }
      }
    }
  }
})
